Basic Exercise


Exercise 1

// Declare two variables num1 and num2 and assign them some numerical values.
// Calculate and print the sum of num1 and num2.

   
var num1 = 10;
var num2 = 20;
console.log(num1 + num2);
document.getElementById("ex1").innerText = num1 + num2;

Exercise 2

Declare two variables num3 and num4 and assign them some numerical values.
Calculate and print the difference between num3 and num4.

   
var num3 = 80;
var num4 = 30;
console.log(num3 - num4);
document.getElementById("ex2").innerText = num3 - num4;

Exercise 3

Declare two variables num5 and num6 and assign them some numerical values.
Calculate and print the multiplication of num5 and num6.

   
var num5 = 80;
var num6 = 30;
console.log(num5 * num6);
document.getElementById("ex3").innerText = num5 * num6;

Exercise 4

Declare two variables num7 and num8 and assign them some numerical values.
Calculate and print the result of dividing num7 by num8.

   
var num7 = 60;
var num8 = 30;
console.log(num7 / num8);
document.getElementById("ex4").innerText = num7 / num8;

Exercise 5

Declare two variables num9 and num10 and assign them some numerical values.
Calculate and print the when num9 is divided by num10.

   
var num9 = 97;
var num10 = 30;
console.log(num9 % num10);
document.getElementById("ex5").innerText = num9 % num10;
    

Exercise 6

Declare a variable num11 and assign it a numerical value.
Increment num11 by 1 and print the result.

   
var num11 = 97;
num11++;
console.log(num11);
document.getElementById("ex6").innerText = num11;

Exercise 7

Declare a variable num12 and assign it a numerical value.
decrement num12 by 1 and print the result.

   
var num12 = 97;
num12--;
console.log(num12);
document.getElementById("ex7").innerText = num12;